home *** CD-ROM | disk | FTP | other *** search
- IFND DPKERNEL_I
- DPKERNEL_I SET 1
-
- **
- ** $VER: dpkernel.i V0.9B
- **
- ** General include file for programs using the DPKernel.
- **
- ** (C) Copyright 1996-1997 DreamWorld Productions.
- ** All Rights Reserved.
- **
- **
-
- IFND LIBRARIES_DPKERNEL_LIB_I
- include 'modules/dpkernel_lib.i'
- include 'modules/screens.i'
- include 'modules/blitter.i'
- include 'modules/sound.i'
- ENDC
-
- IFND SYSTEM_TYPES_I
- include 'system/types.i'
- ENDC
-
- IFND SYSTEM_REGISTER_I
- include 'system/register.i'
- ENDC
-
- ****************************************************************************
-
- DPKVersion = 0 ;Version for these includes.
- DPKRevision = 9 ;Revision for these includes.
-
- SKIPENTRY = 0 ;Used to skip to the next entry.
- ENDLIST = -1 ;Used to terminate a list.
- LISTEND = -1 ;Synonym for ENDLIST.
- TAGEND = 0 ;Used to terminate a tag list.
- DEFAULT = 0
-
- TBYTE = 0 ;Flags used for constructing tag lists.
- TLONG = (1<<31)
- TWORD = (1<<30)
- TAPTR = (1<<29)|TLONG
- TSTEPIN = (1<<28)
- TSTEPOUT = (1<<27)
- TTRIGGER = (1<<26)
-
- IFND TAG_IGNORE
- TAG_IGNORE = 1
- TAG_MORE = 2
- TAG_SKIP = 3
- ENDC
-
- JMP_AMIGA = 0
-
- GET_NOTRACK = $00010000 ;Disables tracking on an object.
-
- ****************************************************************************
- * Header used in all objects.
-
- STRUCTURE Head,0
- WORD HEAD_ID ;Object Identifier, eg ID_PICTURE
- WORD HEAD_Version ;Version of this object.
- APTR HEAD_Class ;Pointer to relevant system object.
- APTR HEAD_Stats ;Private.
- LABEL HEAD_SIZEOF
-
- STRUCTURE Stats,0 ;This structure is completely private.
- LONG STATS_Key ;Resource key.
- APTR STATS_ChildPrivate ;Available for child objects.
- LONG STATS_Flags ;General flags.
-
- ST_LOCK = $00000001
-
- ****************************************************************************
- * RawData object.
-
- RAWVERSION = 1
- TAGS_RAWDATA = ((ID_SPCTAGS<<16)|ID_RAWDATA)
-
- STRUCTURE RD,HEAD_SIZEOF ;Standard structure header.
- LONG RD_Size ;Size of the data in bytes.
- APTR RD_Data ;Pointer to the data.
- BYTE RD_AFlags ;Private.
- BYTE RD_Pad ;Private.
- LABEL RD_SIZEOF
-
- ****************************************************************************
- * This macro will allow you to run a DPK program directly (ie no StartDPK),
- * and still retain compatibility on other platforms. It will also set up
- * the self-destruct mechanism so that hitting left-amiga and delete will
- * destroy your task and leave the system 100% intact with all resources.
- *
- * Usage: STARTDPK
-
- STRUCTURE dp1,0
- LONG DPK_ID
- WORD DPK_Version
- WORD DPK_DPKType
- LONG DPK_Start
- APTR DPK_DPKBase
- APTR DPK_Name
- APTR DPK_Author
- APTR DPK_Date
- APTR DPK_Copyright
- APTR DPK_Short
- WORD DPK_MinVersion
- WORD DPK_MinRevision
- APTR DPK_GVBase
-
- STARTDPK MACRO
- bra.s StartAmigaDOS ;Jump if running from AmigaDOS.
-
- dc.l "PRGM" ;ID Header.
- dc.w 1 ;Version number.
- dc.w JMP_LVO ;Type of jump table from DPK.
- dc.l StartDPKernel ;Start of program.
- DPKBase dc.l 0 ;DPKBase.
- dc.l ProgName ;Name of the program.
- dc.l ProgAuthor ;Who wrote the program.
- dc.l ProgDate ;Date of compilation.
- dc.l ProgCopyright ;Copyright details.
- dc.l ProgShort ;Short description of program.
- dc.w DPKVersion ;Minimum required DPKernel version.
- dc.w DPKRevision ;Minimum required DPKernel revision.
- GVBase: dc.l 0 ;Global variable base.
-
- StartAmigaDOS:
- MOVEM.L D0-D7/A0-A6,-(SP) ;SP = Save all registers.
- move.l ($4).w,a6 ;a6 = ExecBase
- lea DPKName(pc),a1 ;a1 = Library name.
- moveq #DPKVersion,d0 ;d0 = Version of these includes.
- jsr -552(a6) ;>> = OpenLibrary()
- move.l d0,DPKBase ;ma = Save base.
- beq ProgEnd ;>> = Error, exit.
- move.w #1,DOS
-
- move.l d0,a6 ;a6 = DPKBase.
- lea ProgExit(pc),a0 ;a0 = Pointer to SelfDestruct() cleanup.
- move.l a7,a1 ;a1 = Stack pointer.
- CALL InitDestruct ;>> = Initialise the call.
- bra.s Launch
-
- StartDPKernel:
- MOVEM.L D0-D7/A0-A6,-(SP) ;SP = Save all registers.
- Launch: move.l DPKBase(pc),a6
- moveq #MOD_SCREENS,d0
- sub.l a0,a0
- CALL OpenModule
- move.l d0,SCRModule
- beq.s ProgExit
- move.l d0,a5
- move.l MOD_ModBase(a5),SCRBase
-
- moveq #MOD_SOUND,d0
- sub.l a0,a0
- CALL OpenModule
- move.l d0,SNDModule
- beq.s ProgExit
- move.l d0,a5
- move.l MOD_ModBase(a5),SNDBase
-
- moveq #MOD_BLITTER,d0
- sub.l a0,a0
- CALL OpenModule
- move.l d0,BLTModule
- beq.s ProgExit
- move.l d0,a5
- move.l MOD_ModBase(a5),BLTBase
-
- bsr.s Start\@ ;>> = Start the program.
- tst.l d0 ;d0 = Check for error.
- beq.s ProgExit ;>> = No errors, exit.
- move.l DPKBase(pc),a6
- CALL ErrCode ;>> = Send the error code.
-
- ProgExit:
- move.l DPKBase(pc),a6 ;a6 = DPKBase
- move.l SCRModule(pc),a0
- CALL Free
- move.l BLTModule(pc),a0
- CALL Free
- move.l SNDModule(pc),a0
- CALL Free
-
- tst.w DOS
- beq.s ProgEnd
- CALL CloseDPK ;>> = Close the kernel.
- ProgEnd MOVEM.L (SP)+,D0-D7/A0-A6 ;SP = Return registers.
- moveq #$00,d0 ;d0 = No errors.
- rts
-
- IFNC '\1',''
- .name dc.b "\1",0
- even
- ENDC
-
- DOS: dc.w 0
- SNDBase: dc.l 0
- BLTBase: dc.l 0
- SCRBase: dc.l 0
- SNDModule: dc.l 0
- BLTModule: dc.l 0
- SCRModule: dc.l 0
-
- DPKName: dc.b "GMS:libs/dpkernel.library",0
- even
- Start\@
- ENDM
-
- ******************************************************************************
- * This macro provides an easy way of sending a message to IceBreaker.
- * The DPKBase must be in register a6.
- *
- * Example:
- *
- * MESSAGE "Hello World."
-
- MESSAGE MACRO
- MOVEM.L A5/D7,-(SP)
- moveq #DBG_Message,d7
- lea .text\@(pc),a5
- CALL DebugMessage
- bra.s .cont\@
- .text\@ dc.b \1,0
- even
- .cont\@ MOVEM.L (SP)+,A5/D7
- ENDM
-
- *****************************************************************************
- * Universal errorcodes returned by certain functions. These are further
- * explained in the documentation.
-
- STRUCTURE Errors,0
- BYTE ERR_OK ;Function went OK.
- BYTE ERR_NOMEM ;Not enough memory available.
- BYTE ERR_NOPTR ;A required address pointer is not present.
- BYTE ERR_INUSE ;Previous allocations have not been freed.
- BYTE ERR_STRUCT ;Structure version not supported/not found.
- BYTE ERR_FAILED ;General/Miscellaneous failure.
- BYTE ERR_FILE ;General file error, eg file not found, disk full etc.
- BYTE ERR_BADDATA ;There is an error in the given data.
- BYTE ERR_SEARCH ;An internal search was performed and it failed.
- BYTE ERR_SCRTYPE ;Screen Type not recognised.
- BYTE ERR_MODULE ;Trouble with initialising/using a system module.
- BYTE ERR_RASTCOMMAND ;Invalid raster command detected.
- BYTE ERR_RASTERLIST ;Complete rasterlist failure.
- BYTE ERR_NORASTER ;Expected rasterlist is missing from GS_Rasterlist.
- BYTE ERR_DISKFULL ;Disk full error.
- BYTE ERR_FILEMISSING ;File not found.
- BYTE ERR_WRONGVER ;Wrong version or version not supported.
- BYTE ERR_MONITOR ;Monitor driver not found or cannot be used.
- BYTE ERR_UNPACK ;Problem with unpacking of data.
- BYTE ERR_ARGS ;Invalid arguments passed to function.
- BYTE ERR_NODATA ;No data is available for use.
- BYTE ERR_READ ;Error reading data from file.
- BYTE ERR_WRITE ;Error writing data to file.
- BYTE ERR_LOCK ;Could not obtain lock on object.
- BYTE ERR_EXAMINE ;Could not examine the directory or file.
- BYTE ERR_LOSTCLASS ;This object has lost its class reference.
- BYTE ERR_NOACTION ;This object does not support the required action.
- BYTE ERR_NOSUPPORT ;Object does not support the given data.
- BYTE ERR_MEMORY ;General memory error.
- LABEL ERR_END ;Private code (used by IceBreaker).
-
- ERR_SUCCESS = ERR_OK ;Synonym for ERR_OK.
- ERR_DATA = ERR_BADDATA ;Synonym for ERR_BADDATA.
-
- *****************************************************************************
- * Memory types used by AllocMemBlock(). This is almost identical to the
- * exec definition but CHIP is renamed to VIDEO (displayable memory) and
- * there is an addition of BLIT and SOUND specific memory. CLEARed memory is
- * redundant (all GMS memory is cleared on allocation), REVERSE and NO_EXPUNGE
- * are also no longer needed (NB: GMS uses exec's reverse flag to reduce
- * fragmentation).
-
- MEM_DATA = $00000000 ;Default.
- MEM_PRIVATE = $00000001 ;Memory is for private use.
- MEM_VIDEO = $00000002 ;Suitable for the video display and blitting.
- MEM_BLIT = $00000004 ;For blitting only.
- MEM_SOUND = $00000008 ;Sound/Audio memory for playback of sounds.
- MEM_CODE = $00000010 ;For executing code and storing data.
- MEM_UNTRACKED = $80000000 ;Do not track the memory.
-
- MPRIVATE = MEM_PRIVATE ;Synonym.
-
- MEMB_PRIVATE = 0 ;Public access memory.
- MEMB_VIDEO = 1 ;Displayable memory, blitter compatible.
- MEMB_BLIT = 2 ;Blitter memory.
- MEMB_SOUND = 3 ;Sound memory.
- MEMB_CODE = 4 ;Code and data memory.
- MEMB_UNTRACKED = 31 ;Do not track the memory.
-
- ;IFND SYSTEM_DPKBASE_I
- ;include 'system/dpkbase.i'
- ;ENDC
-
- IFND SYSTEM_MODULES_I
- include 'system/modules.i'
- ENDC
-
- IFND GRAPHICS_BLITTER_I
- include 'graphics/blitter.i'
- ENDC
-
- IFND GRAPHICS_SCREENS_I
- include 'graphics/screens.i'
- ENDC
-
- IFND GRAPHICS_PICTURES_I
- include 'graphics/pictures.i'
- ENDC
-
- IFND SYSTEM_MISC_I
- include 'system/misc.i'
- ENDC
-
- IFND SOUND_SOUND_I
- include 'sound/sound.i'
- ENDC
-
- IFND INPUT_JOYPORTS_I
- include 'input/joyports.i'
- ENDC
-
- IFND INPUT_KEYBOARD_I
- include 'input/keyboard.i'
- ENDC
-
- IFND FILES_FILES_I
- include 'files/files.i'
- ENDC
-
- ENDC ;DPKERNEL_I
-